package com.yonyou.pmclouds.inspectitem.process;

import com.yonyou.pmclouds.basecom.bp.processor.SingleProcessor;
import com.yonyou.pmclouds.basecom.exception.BusinessException;
import com.yonyou.pmclouds.inspectitem.entity.InspectItemBillStatusConst;
import com.yonyou.pmclouds.inspectitem.entity.InspectItemVO;

/**
 * 检查项修改前规则
 * @author wuhaok
 *
 */
public class InspectItemUpdateBeforeProcess implements SingleProcessor<InspectItemVO>{

    @Override
    public void process(InspectItemVO vo, InspectItemVO orig) throws BusinessException {
        if(vo == null){
            throw new BusinessException("单据不能为空！");
        }
        byte status = vo.getBillstatus();
        // 判断是否为三种状态中的一种
        if (status != InspectItemBillStatusConst.BILLSTATUS_PASS &&
                status != InspectItemBillStatusConst.BILLSTATUS_NO_PASS &&
                status != InspectItemBillStatusConst.BILLSTATUS_NOT_FIT) {
            throw new BusinessException("请选择检查项状态为必选项!");
        }
        if (vo.getMemo() != null && vo.getMemo().length() > 300) {
            throw new BusinessException("检查项备注最多只能有300个字！");
        }
    }
}

